// 订单状态枚举
export enum OrderStatus {
  PENDING_PAYMENT = 1,    // 待付款
  PENDING_SHIPMENT = 2,   // 待发货
  PENDING_RECEIPT = 3,    // 待收货
  COMPLETED = 4,          // 已完成
  CANCELLED = 5,          // 已取消
  REFUNDING = 6           // 退款中
}

// 支付状态枚举
export enum PaymentStatus {
  UNPAID = 0,    // 未支付
  PAID = 1       // 已支付
}

// 物流状态枚举
export enum ShippingStatus {
  UNSHIPPED = 0,    // 未发货
  SHIPPED = 1,      // 已发货
  RECEIVED = 2      // 已收货
}

// 支付方式枚举
export enum PaymentMethod {
  ALIPAY = 1,      // 支付宝
  WECHAT = 2,      // 微信
  BANK_CARD = 3    // 银行卡
}

// 订单基础信息接口
export interface Order {
  id: number;
  orderNo: string;
  userId: number;
  orderStatus: OrderStatus;
  paymentStatus: PaymentStatus;
  shippingStatus: ShippingStatus;
  consigneeName: string;
  consigneePhone: string;
  consigneeAddress: string;
  totalAmount: number;
  goodsAmount: number;
  shippingFee: number;
  pointsAmount: number;
  paymentMethod?: PaymentMethod;
  paymentTime?: Date;
  shippingTime?: Date;
  confirmTime?: Date;
  deliveryCompany?: string;
  deliveryNo?: string;
  buyerMessage?: string;
  sellerRemark?: string;
  autoConfirmDay: number;
  createdAt: Date;
  updatedAt: Date;
}

// 订单商品项接口
export interface OrderItem {
  id: number;
  orderId: number;
  productId: number;
  skuId?: number;
  productName: string;
  productImage?: string;
  skuSpecifications?: any;
  price: number;
  quantity: number;
  totalAmount: number;
  createdAt: Date;
}

// 订单详情接口（包含商品项）
export interface OrderDetail extends Order {
  items: OrderItem[];
  user?: {
    id: number;
    username: string;
    phone?: string;
    email?: string;
  };
}

// 创建订单请求接口
export interface CreateOrderRequest {
  userId: number;
  consigneeName: string;
  consigneePhone: string;
  consigneeAddress: string;
  shippingFee?: number;
  pointsAmount?: number;
  buyerMessage?: string;
  items: {
    productId: number;
    skuId?: number;
    quantity: number;
    price: number;
  }[];
}

// 更新订单请求接口
export interface UpdateOrderRequest {
  orderStatus?: OrderStatus;
  paymentStatus?: PaymentStatus;
  shippingStatus?: ShippingStatus;
  paymentMethod?: PaymentMethod;
  deliveryCompany?: string;
  deliveryNo?: string;
  sellerRemark?: string;
}

// 订单查询参数接口
export interface OrderQueryParams {
  page?: number;
  limit?: number;
  orderNo?: string;
  userId?: number;
  orderStatus?: OrderStatus;
  paymentStatus?: PaymentStatus;
  shippingStatus?: ShippingStatus;
  startDate?: string;
  endDate?: string;
  consigneeName?: string;
  consigneePhone?: string;
  sort?: string;
  order?: 'ASC' | 'DESC';
}

// 订单统计接口
export interface OrderStats {
  totalOrders: number;
  pendingPayment: number;
  pendingShipment: number;
  pendingReceipt: number;
  completed: number;
  cancelled: number;
  refunding: number;
  totalAmount: number;
  todayOrders: number;
  todayAmount: number;
}

// 购物车项接口
export interface CartItem {
  id: number;
  userId: number;
  productId: number;
  skuId?: number;
  quantity: number;
  price: number;
  selected: boolean;
  createdAt: Date;
  updatedAt: Date;
  product?: {
    id: number;
    name: string;
    image?: string;
    status: number;
  };
  sku?: {
    id: number;
    skuCode: string;
    specifications?: any;
    price: number;
    stockQuantity: number;
  };
}

// 购物车操作请求接口
export interface CartRequest {
  productId: number;
  skuId?: number;
  quantity: number;
}

// 更新购物车请求接口
export interface UpdateCartRequest {
  quantity?: number;
  selected?: boolean;
}